/**
 * Created by ospip on 2017/9/19.
 * Copyright (c) 2017 LLAP. All rights reserved.
 */
public class Palindrome {
    protected String str;

    public Palindrome(String str) {
        this.str = str;
    }

    public String toString() {
        String ret = "";
        if (this.isPalindrome()) ret = "<Palindrome String: ";
        else ret = "<Non-palindrome String: ";
        ret += str + ">";
        return ret;
    }

    public boolean isPalindrome() {
        int length = str.length(), i, j;
        if (length % 2 == 0) i = length / 2 - 1;
        else i = length / 2;
        j = length / 2;
        char[] strArray = str.toCharArray();
        for (; i != 0 && j != length - 1; --i, ++j) {
            if (strArray[i] != strArray[j]) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        Palindrome s1 = new Palindrome("lalalala");
        Palindrome s2 = new Palindrome("asdfdsa");
        Palindrome s3 = new Palindrome("asdffdsa");
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
    }
}
